﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using Weixin.BLL.ChinaTax;
using Weixin.Entity.ChinaTax;
using Weixin.Utils;

namespace Weixin.Web
{
    public partial class Register : System.Web.UI.Page
    {
        #region jssdk
        protected string noncestr = string.Empty;
        protected string jsapi_ticket = string.Empty;
        protected string timestamp = string.Empty;
        protected string signature = string.Empty;

        protected string url = string.Empty;
        protected string title = string.Empty;
        protected string desc = string.Empty;
        #endregion
        protected void Page_Load(object sender, EventArgs e)
        {
            GetJssdk();

            try
            {
                if (Request.QueryString["act"] == "save")
                {
                    user1BLL _User1BLL = user1BLL.GetInstance();
                    int rtn=_User1BLL.Register(Request.Form["txtEmail"], Request.Form["txtMobile"], Request.Form["txtPassword"], Request.Form["txtRecommandUser"], IPHelper.GetClientIP());
                    if (rtn ==1)
                    {
                        Response.Redirect("Success.aspx?tips=注册成功");
                    }
                    else if (rtn == -2 || rtn == -3)
                    {
                        Response.Redirect("Success.aspx?tips=用户名重复，请重新注册");
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Log4Net.Error(ex.Message + ";" + ex.StackTrace);
            }

        }

        protected void GetJssdk()
        {
            WX wx = new WX();
            url = Request.Url.ToString().IndexOf("#") > -1 ? Request.Url.ToString().Substring(0, Request.Url.ToString().IndexOf("#")) : Request.Url.ToString();
            string[] arr = wx.GetJSSDK(url);
            noncestr = arr[0];
            jsapi_ticket = arr[1];
            timestamp = arr[2];
            signature = arr[3];

            title = "中国税务咨询师";
            desc = "免费注册会员，最权威税务第一门户网站,最专业税务咨询网站";
        }
    }
}